		
		package servlet.user;
		
		import java.io.IOException;
		import javax.servlet.ServletException;
		import javax.servlet.http.HttpServlet;
		import javax.servlet.http.HttpServletRequest;
		import javax.servlet.http.HttpServletResponse;
		
		import enitys.User;
		
		import service.UserManager;
		
		public class UpdateUser extends HttpServlet {
		
			/**
			 * 
			 */
			private static final long serialVersionUID = 1L;
		
			/**
			 * Constructor of the object.
			 */
			public UpdateUser() {
				super();
			}
		
			
			/**
			 * The doGet method of the servlet. <br>
			 *
			 * This method is called when a form has its tag value method equals to get.
			 * 
			 * @param request the request send by the client to the server
			 * @param response the response send by the server to the client
			 * @throws ServletException if an error occurred
			 * @throws IOException if an error occurred
			 */
			public void doGet(HttpServletRequest request, HttpServletResponse response)
					throws ServletException, IOException {
		
				//获取用户id
				int id = Integer.parseInt(request.getParameter("id").toString());
				//获取业务对象实例  查询用户信息
				UserManager manager = UserManager.getInstance();
				User info =new User();
				info=manager.getUserById(id);
				//把用户信息设置到request中
				request.setAttribute("name", info.getUsername());
				request.setAttribute("email", info.getEmail());
				request.setAttribute("password", info.getPassword());
				request.setAttribute("class", info.getClasses());
				request.setAttribute("id", info.getS_id());
				//跳转到相应的业务界面
				this.getServletConfig().getServletContext().getRequestDispatcher("/jsp/user_info/studentupdate.jsp").forward(request, response);
			}
		
			/**
			 * The doPost method of the servlet. <br>
			 *
			 * This method is called when a form has its tag value method equals to post.
			 * 
			 * @param request the request send by the client to the server
			 * @param response the response send by the server to the client
			 * @throws ServletException if an error occurred
			 * @throws IOException if an error occurred
			 */
			public void doPost(HttpServletRequest request, HttpServletResponse response)
					throws ServletException, IOException {
					doGet(request,response);
			}
		}
